<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Math lib</title>
<link rel="stylesheet" type="text/css" href="math.css">
<script src="plot.js" type="text/javascript"></script>

<style>
</style>

</head>
<body onload="push()">

<div class="display" id="graph">
</div>

<textarea id="input" cols="80"></textarea>
<h3>Examples</h3>
<code>
<p>Math.exp(-x*x*.05)*Math.cos(3*x)*Math.sin(10*x)*2</p>
<p>[[34,44],[5,57],[1.3445, 0.0430],[31, 4], [25, 2], [1, 26], [43, 7], [4, 7], [32, 75]]</p>
</code>
<br/><button onclick="up()">Plot</button><button onclick="push()">Add</button>
<script>

function parse(){
var txt=document.getElementById("input"),
	dat=txt.value;
txt.rows =3;
try{
	dat=JSON.parse(dat);
}catch(e){
	//console.log("JSON failed, trying 'new Function'...");
	try{
		dat=new Function("return function(x){ return " + dat + "}" )();
	}catch(er){console.warn("Could not parse:",er)}
}
return dat;
}

function up(){
if(t[0])
	t[0].Parse(parse());
}

function push(){
var Plot=Smal.Plot,
	dv=document.getElementById("graph"),
	t = this.t = this.t || [];
t.push(Plot(parse(), {scale:40,width:600,height:300,parent:dv,min:0}));
//t.push(Plot( ,{,width:412,parent:dv}));
}
</script>
</body>
</html>